/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GraphViz;

import QASystem.QAProvider;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JPanel;

/**
 *
 * @author Raito
 */
public class ImagePanel extends JPanel {

    private Image graphicsImage;

    public ImagePanel() {
    }

    @Override
    public void paint(Graphics g) {
        // TODO Auto-generated method stub
        super.paint(g);
        if (graphicsImage != null) {
            g.drawImage(graphicsImage, 0, 0, this);
        }
    }

    public void setImage(GraphViz gv){
        graphicsImage = Toolkit.getDefaultToolkit().createImage(gv.getGraph(gv.getDotSource(), "png"));
        this.repaint();
    }
}
